<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" style="margin-top: 15px">
    <div class="layui-form-item" style="margin-left: 30%">
        <button class="layui-btn" id="addBtn" lay-submit lay-filter="addBtn">一键开启全部闸门</button>
    </div>
</form>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<style type="text/css">
    .layui-table-header {
        width: 1289px;
    }
</style>
<script>
    var allStr;

    $(function () {
        var tableIns = createTable({
            url: 'list',
            cols: [[
                {field: 'deviceName', title: '设备名称', width: 200}, {
                    field: 'deviceId',
                    title: '设备编号',
                    width: 160
                }, {
                    field: 'deviceIp',
                    title: '设备IP地址',
                    width: 160
                }, {
                    field: 'type', title: '设备类型', width: 100,
                    templet: '#typeTpl'
                }, {
                    field: 'status', title: '运行状态', width: 100,
                    templet: '#statusTpl'
                }
                , {field: 'examineeHallName', title: '所在考场', width: 180}, {
                    field: 'createTime',
                    title: '创建时间',
                    width: 180
                }, {
                    fixed: 'right',
                    title: '操作',
                    width: 200,
                    align: 'center',
                    toolbar: '#opbar'
                }
            ]]
        });

        layui.table.on('tool(grid)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if (layEvent === 'edit') { //编辑
                openDialog({
                    url: "/backend/security/deviceInfo/detail?id=" + data.id,
                    area: ["45%", "50%"]
                });
            }
        });

        layui.form.on('submit(addBtn)', function () {
            openDialog({
                url: "/backend/security/deviceInfo/detail",
                area: ["45%", "50%"]
            });
            return false;
        });


        layui.form.on('submit(searchBtn)', function (data) {
            tableIns.reload({
                where: data.field
            });
            return false;
        });
    })
</script>
<script type="text/html" id="typeTpl">
    {{#  if(d.type ===1){ }}
    <span>人脸闸机</span>
    {{#  } }}
</script>
<script type="text/html" id="statusTpl">
    {{#  if(d.status ===1){ }}
    <span style="color: #FF0000;">离线</span>
    {{#  } else { }}
    <span style="color: green;">运行中</span>
    {{#  } }}
</script>
<script type="text/html" id="opbar">
    <a class="layui-btn layui-btn-xs" lay-event="openDv">开闸</a>
</script>
</body>
</html>
